/**
 * Copyright &copy; 2012-2016 <a href="https://www.kaaction.com">KAA</a> All rights reserved All rights reserved.
 */
package com.kaaction.modules.mer.service;

import java.util.List;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.kaaction.common.persistence.Page;
import com.kaaction.common.service.CrudService;
import com.kaaction.modules.mer.entity.OperationSubjectDetail;
import com.kaaction.modules.mer.dao.OperationSubjectDetailDao;

/**
 * 运营专题明细Service
 * @author huanghaiming
 * @version 2017-07-04
 */
@Service
@Transactional(readOnly = true)
public class OperationSubjectDetailService extends CrudService<OperationSubjectDetailDao, OperationSubjectDetail> {

	public OperationSubjectDetail get(String id) {
		return super.get(id);
	}
	
	public List<OperationSubjectDetail> findList(OperationSubjectDetail operationSubjectDetail) {
		return super.findList(operationSubjectDetail);
	}
	
	public Page<OperationSubjectDetail> findPage(Page<OperationSubjectDetail> page, OperationSubjectDetail operationSubjectDetail) {
		return super.findPage(page, operationSubjectDetail);
	}
	
	@Transactional(readOnly = false)
	public void save(OperationSubjectDetail operationSubjectDetail) {
		super.save(operationSubjectDetail);
	}
	
	@Transactional(readOnly = false)
	public void delete(OperationSubjectDetail operationSubjectDetail) {
		super.delete(operationSubjectDetail);
	}

	@Transactional(readOnly = false)
	public void insertOperaSubDtl(String id, String opesubId) {
		
		OperationSubjectDetail operationSubjectDetail = new OperationSubjectDetail();
		
		String[] ids = id.split(",");
		for(String opercontentId:ids){
			int cnt = super.dao.setCnt(opercontentId,opesubId);
			if(cnt==0){
				operationSubjectDetail.setOpercontentId(opercontentId);
				operationSubjectDetail.setOpesubId(opesubId);
				operationSubjectDetail.preInsert();
				super.dao.insert(operationSubjectDetail);
			}
		
		}
		
	}

	@Transactional(readOnly = false)
	public void updateOpeSubtitle(OperationSubjectDetail operationSubjectDetail) {
		super.dao.updateOpeSubtitle(operationSubjectDetail);
	}
	
}